﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class Konsole
    ''' <summary>
    ''' Alles klein!!!
    ''' </summary>
    ''' <remarks></remarks>
    Public Enum KonsolenBefehle
        quit
        funnymessage
        help
        getfps
        changewindowresolution
        changewindowstate
        changeconsoleresolution
        usewindowsconsole
        commanderwarsisbest
        showgameorders
        changedebugmode
        battleanimations
        netprotocol
        speechrecoqassembly
        getvalue
        terminategame
        changecursor
        'AI Commands
        aibreak
        aicontinue
        change_strategy_loading
        get_ai_strategies
        'Scritp
        checkscript
        launchscript
        'Sonstiges
        createmasks
        changeiniai
        changemapai
        'Network
        testnetwork
        'Map-Backup
        importtxtmaps
        exporttxtmaps
        updatedirectoryandfiles
        updatefiles
        createcolortables
        updatemaps
        updatemap
        saveasoldmap
        'Lobby
        viewmembers
        'Sonstiges
        splitpicture
        convertpictures
        showaidata
    End Enum
    Public Enum Settings
        Adapter
        ScreenWidth
        ScreenHeight
        Resourcepath
        Screen_ratio
        Stratch_factor
        Game_Speed
        Scroll_sensitivity
        Invert_Mouse
        Speech_listening
        Speech_sensitivity
        Autosave
        Last_Game
        Battleanimations
        Captureanimations
        LoadingTime
        Language
        Autor
        Music_Sound
        Background_music
        Gamemode
        Text_Scroll_speed
        Windowed
        Fullscreen_Width
        Fullscreen_Height
        CursorOnMap
        Terrain_style
        CoListAW
        CoListAW2
        CoListAWDC
        CoListAWDS
        CoListCoW
        CoListCoW2
        Unit_List1
        Unit_List2
        Unit_List3
        Record
        InfoMenu
        AutoResizeWindow
        Taskbarmode
        StepsBackward
        AISpeech
        Script_Writer_Size
        ShowInvalidCode
        Quality
        _3D
        Paint_everything
        Animation_Speed_3D
        Mouselighting
        Fog_3D
        _2D3D
        Key_Up
        Key_Down
        Key_Right
        Key_Left
        Key_Confirm
        Key_Cancel
        Key_Next
        Key_Select
        Key_change_Battlefield
        Key_Quicksave1
        Key_Quicksave2
        Key_Quickload1
        Key_Quickload2
        Key_Chat
        Key_TeamChat
        Key_Screenshot
        Key_Forward
        Key_Backward
        Key_Scrollen
        SpeechRecoq
        Key_Console
        Use_Windows_Console
        Show_Orders_during_Game
        Auto_End_Turn
        Show_Tooltips
        Hide_Cursor
        ShowAIData
        WindowsKonsolenausgabe
    End Enum
#Region "Cheats"
    Public Shared CheatMode As Boolean = False
        ''' <summary>
        ''' All cheats inside this Game.
        ''' </summary>
        ''' <remarks></remarks>
    Public Enum Cheats
        setunithp
        setplayermoney
        addplayermoney
        setammo
        setfuel
        power_of_koshi
        power_of_sonja
        power_of_colin
        powercharge
        power_of_sami
        changeplayercontrol
        spawnunit
        areahide
        createfog
        defeatplayer
        addwaitunit
        setfirecounter
        damagewave
        victory
        setco
        sethp
        createunit
        createcoclone
        dialog
        changecopowerstate
		winworldmapmap
		selectableworldmapmap
		setworldmapmap
		removelockedunit
        'Userdata
        unlock_all_cos

    End Enum
    ''' <summary>
    ''' Some cheats for some Gametests
    ''' </summary>
    ''' <param name="Code"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function Cheat(ByVal Code As String, ByVal Parameter() As String)
        If Objektverwalter.Spielfeld IsNot Nothing And CheatMode Then
            If Not Hauptmenue.Connection.Connected Then
                Code = Code.Replace(" ", "_")
                Select Case Code.ToLower
					case cheats.setworldmapmap.tostring
						If Parameter.Length = 2 Then
                            If IsNumeric(Parameter(0)) and IsNumeric(Parameter(1))  Then
								 Hauptmenue.NetzBefehlRecieved("ScriptEvent|SetWorldmapMap|" + Parameter(0) +"|" + Parameter(1))
							end if
						end if
                    Case Cheats.removelockedunit.ToString
                        If Parameter.Length = 2 Then
                            Hauptmenue.NetzBefehlRecieved("ScriptEvent|RemoveLockedUnit|" + Parameter(0) + "|" + Parameter(1))
                        End If
					case cheats.selectableworldmapmap.tostring
						If Parameter.Length = 1 Then
                            If IsNumeric(Parameter(0))  Then
								 Hauptmenue.NetzBefehlRecieved("ScriptEvent|SelectableWorldmapMap|" + Parameter(0))
							end if
						end if
					case cheats.winworldmapmap.tostring
						If Parameter.Length = 1 Then
                            If IsNumeric(Parameter(0))  Then
								 Hauptmenue.NetzBefehlRecieved("ScriptEvent|WinWorldmapMap|" + Parameter(0))
							end if
						end if
                    Case Cheats.changecopowerstate.ToString
                        If Parameter.Length = 2 Then
                            If IsNumeric(Parameter(0)) And IsBoolean(Parameter(0)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|ChangeCOPowerstate|" + Parameter(0) + "|" + Parameter(1))
                            End If
                        End If
                    Case Cheats.dialog.ToString
                        If Parameter.Length = 6 Then
                            If IsNumeric(Parameter(4)) And IsNumeric(Parameter(5)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|Dialog|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3) + "|" + Parameter(4) + "|" + Parameter(5))
                            End If
                        End If
                    Case Cheats.createcoclone.ToString
                        If Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|CreateCOClone|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3))
                            End If
                        End If
                    Case Cheats.createunit.ToString
                        If Parameter.Length = 7 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) And IsNumeric(Parameter(4)) And IsBoolean(Parameter(6)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|CreateUnit|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3) + "|" + Parameter(4) + "|" + Parameter(5) + "|" + Parameter(6))
                            End If
                        End If
                    Case Cheats.sethp.ToString
                        If Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|SetHP|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3))
                            End If
                        End If
                    Case Cheats.setco.ToString
                        If Parameter.Length = 3 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|SetCO|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2))
                            End If
                        End If
                    Case Cheats.victory.ToString
                        If Parameter.Length = 1 Then
                            If Parameter(0).Length = 1 Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|Victory|" + Parameter(0))
                            End If
                        End If
                    Case Cheats.damagewave.ToString
                        If Parameter.Length = 2 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|DamageWave|" + Parameter(0) + "|" + Parameter(1))
                            End If
                        End If
                    Case Cheats.setfirecounter.ToString
                        If Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|SetFireCounter|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3))
                            End If
                        End If
                    Case Cheats.addwaitunit.ToString
                        If Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|AddWaitUnit|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3))
                            End If
                        End If
                    Case Cheats.defeatplayer.ToString
                        If Parameter.Length = 1 Then
                            If IsNumeric(Parameter(0)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|DefeatPlayer|" + Parameter(0))
                            End If
                        End If
                    Case Cheats.areahide.ToString
                        If Parameter.Length = 5 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) And IsBoolean(Parameter(4)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|UnhideArea|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3) + "|" + Parameter(4))
                            End If
                        End If
                    Case Cheats.createfog.ToString
                        If Parameter.Length = 6 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) And IsNumeric(Parameter(4)) And IsNumeric(Parameter(5)) Then
                                Hauptmenue.NetzBefehlRecieved("ScriptEvent|CreateFog|" + Parameter(0) + "|" + Parameter(1) + "|" + Parameter(2) + "|" + Parameter(3) + "|" + Parameter(4) + "|" + Parameter(5))
                            End If
                        End If
                    Case Cheats.power_of_koshi.ToString
                        'Kriegsnebel
                        If Objektverwalter.Spielfeld.Regeln.Nebel < Nebelarten.Aufklaerungsnebel Then
                            Objektverwalter.Spielfeld.Regeln.Nebel += 1
                            Objektverwalter.Spielfeld.Sichterstellen()
                        End If
                    Case Cheats.power_of_sonja.ToString
                        Objektverwalter.Spielfeld.Regeln.Nebel = Nebelarten.Aus
                        Objektverwalter.Spielfeld.Sichterstellen()
                    Case Cheats.power_of_colin.ToString
                        Objektverwalter.Spielfeld.AktuellerSpieler.AddFonds(10000)
                    Case Cheats.powercharge.ToString
                        Objektverwalter.Spielfeld.AktuellerSpieler.KOS(0).Gabeleiste = (Objektverwalter.Spielfeld.AktuellerSpieler.KOS(0).Gabekosten + Objektverwalter.Spielfeld.AktuellerSpieler.KOS(0).SpezialgabeKosten) * Objektverwalter.Spielfeld.AktuellerSpieler.KOS(0).Sternkosten
                        If IsNothing(Objektverwalter.Spielfeld.AktuellerSpieler.KOS(1)) = False Then
                            Objektverwalter.Spielfeld.AktuellerSpieler.KOS(1).Gabeleiste = (Objektverwalter.Spielfeld.AktuellerSpieler.KOS(1).Gabekosten + Objektverwalter.Spielfeld.AktuellerSpieler.KOS(1).SpezialgabeKosten) * Objektverwalter.Spielfeld.AktuellerSpieler.KOS(1).Sternkosten
                        End If
                    Case Cheats.power_of_sami.ToString
                        For I = 0 To Objektverwalter.Spielfeld.Spieler.Length - 1
                            If Objektverwalter.Spielfeld.Spieler(I).Team <> Objektverwalter.Spielfeld.AktuellerSpieler.Team Then
                                Objektverwalter.Spielfeld.Regeln.Besiegt(I) = True
                            Else
                                Objektverwalter.Spielfeld.Regeln.Besiegt(I) = False
                            End If
                        Next
                        Objektverwalter.Spielfeld.Regeln.CheckSieg()
                    Case Cheats.setunithp.ToString
                        Dim X As Integer
                        Dim Y As Integer
                        Dim Z As Integer
                        Dim LP As Single
                        If Parameter.Length = 3 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = 0
                                LP = Parameter(2)
                            End If
                        ElseIf Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = Parameter(2)
                                If Z > ObjektSpielfeld.Luftschlacht Then Z = ObjektSpielfeld.Luftschlacht
                                If Z < ObjektSpielfeld.Bodenschlacht Then Z = ObjektSpielfeld.Bodenschlacht
                                LP = Parameter(3)
                            End If
                        End If
                        If Objektverwalter.Spielfeld.OnMap(X, Y) Then
                            If Objektverwalter.Spielfeld.Einheiten(X, Y, Z) IsNot Nothing Then
                                If LP <= 0 Then LP = 1
                                If LP > 100 Then LP = 100
                                Objektverwalter.Spielfeld.Einheiten(X, Y, Z).Leben = LP
                            End If
                        End If
                    Case Cheats.setplayermoney.ToString
                        Dim Spieler As Integer
                        Dim Fonds As Integer
                        If Parameter.Length = 1 Then
                            If IsNumeric(Parameter(0)) Then
                                Fonds = Parameter(0)
                                Spieler = Objektverwalter.Spielfeld.AktuellerSpieler.Spieler
                            End If
                        ElseIf Parameter.Length = 2 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) Then
                                Fonds = Parameter(1)
                                Spieler = Parameter(0)
                                If Spieler < 1 Then Spieler = 1
                                If Spieler >= Objektverwalter.Spielfeld.Spieler.Length Then Spieler = Objektverwalter.Spielfeld.Spieler.Length - 1
                            End If
                        End If
                        Objektverwalter.Spielfeld.Spieler(Spieler).SetFonds(Fonds)
                    Case Cheats.addplayermoney.ToString
                        Dim Spieler As Integer
                        Dim Fonds As Integer
                        If Parameter.Length = 1 Then
                            If IsNumeric(Parameter(0)) Then
                                Fonds = Parameter(0)
                                Spieler = Objektverwalter.Spielfeld.AktuellerSpieler.Spieler
                            End If
                        ElseIf Parameter.Length = 2 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) Then
                                Fonds = Parameter(1)
                                Spieler = Parameter(0)
                                If Spieler < 1 Then Spieler = 1
                                If Spieler >= Objektverwalter.Spielfeld.Spieler.Length Then Spieler = Objektverwalter.Spielfeld.Spieler.Length - 1
                            End If
                        End If
                        Objektverwalter.Spielfeld.Spieler(Spieler).AddFonds(Fonds)
                    Case Cheats.setammo.ToString
                        Dim X As Integer
                        Dim Y As Integer
                        Dim Z As Integer
                        Dim Ammo As Integer
                        If Parameter.Length = 3 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = 0
                                Ammo = Parameter(2)
                            End If
                        ElseIf Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = Parameter(2)
                                If Z > ObjektSpielfeld.Luftschlacht Then Z = ObjektSpielfeld.Luftschlacht
                                If Z < ObjektSpielfeld.Bodenschlacht Then Z = ObjektSpielfeld.Bodenschlacht
                                Ammo = Parameter(3)
                            End If
                        End If
                        If Objektverwalter.Spielfeld.OnMap(X, Y) Then
                            If Objektverwalter.Spielfeld.Einheiten(X, Y, Z) IsNot Nothing Then
                                Objektverwalter.Spielfeld.Einheiten(X, Y, Z).Munition = Ammo
                            End If
                        End If
                    Case Cheats.setfuel.ToString
                        Dim X As Integer
                        Dim Y As Integer
                        Dim Z As Integer
                        Dim Fuel As Integer
                        If Parameter.Length = 3 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = 0
                                Fuel = Parameter(2)
                            End If
                        ElseIf Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = Parameter(2)
                                If Z > ObjektSpielfeld.Luftschlacht Then Z = ObjektSpielfeld.Luftschlacht
                                If Z < ObjektSpielfeld.Bodenschlacht Then Z = ObjektSpielfeld.Bodenschlacht
                                Fuel = Parameter(3)
                            End If
                        End If
                        If Objektverwalter.Spielfeld.OnMap(X, Y) Then
                            If Objektverwalter.Spielfeld.Einheiten(X, Y, Z) IsNot Nothing Then
                                Objektverwalter.Spielfeld.Einheiten(X, Y, Z).Treibstoff = Fuel
                            End If
                        End If
                    Case Cheats.changeplayercontrol.ToString
                        Dim X As Integer
                        Dim Y As Integer
                        Dim Z As Integer
                        Dim NewPlayer As Integer
                        If Parameter.Length = 3 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = 0
                                NewPlayer = Parameter(2)
                            End If
                        ElseIf Parameter.Length = 4 Then
                            If IsNumeric(Parameter(0)) And IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                X = Parameter(0)
                                Y = Parameter(1)
                                Z = Parameter(2)
                                If Z > ObjektSpielfeld.Luftschlacht Then Z = ObjektSpielfeld.Luftschlacht
                                If Z < ObjektSpielfeld.Bodenschlacht Then Z = ObjektSpielfeld.Bodenschlacht
                                NewPlayer = Parameter(3)
                            End If
                        End If
                        If Objektverwalter.Spielfeld.OnMap(X, Y) Then
                            If Objektverwalter.Spielfeld.Einheiten(X, Y, Z) IsNot Nothing Then
                                Objektverwalter.Spielfeld.Einheiten(X, Y, Z).Spieler = NewPlayer
                            End If
                            If Objektverwalter.Spielfeld.Landschaften(X, Y, Z).Gebaeude IsNot Nothing Then
                                Dim G As ObjektGebaeude = Objektverwalter.Spielfeld.Landschaften(X, Y, Z).Gebaeude
                                If G.Rechteck.Width = Hauptmenue.Feldbreite And G.Rechteck.Height = 2 * Hauptmenue.Feldbreite Then
                                    G.Spieler = NewPlayer
                                End If
                            End If
                            Objektverwalter.Spielfeld.Regeln.CheckSieg()
                        End If
                    Case Cheats.spawnunit.ToString
                        If Parameter.Length = 4 Then
                            If Objektverwalter.Spielfeld IsNot Nothing Then
                                If IsNumeric(Parameter(1)) And IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                                    Dim Spieler As Integer = Parameter(1)
                                    Dim X As Integer = Parameter(2)
                                    Dim Y As Integer = Parameter(3)
                                    If Spieler > 0 And Spieler < Objektverwalter.Spielfeld.Spieler.Length Then
                                        Objektverwalter.Spielfeld.PlaceUnit(ObjektLadeklasse.NewEinheit(Parameter(0).ToUpper, Spieler, X, Y, False), X, Y, 0)
                                    End If
                                End If
                            End If
                        End If
                    Case Else
                        Return False
                End Select
                AendereKonsolenStatus()
                Return True
            Else
                Return False
            End If
        Else
            If Not Hauptmenue.Connection.Connected Then
                Code = Code.Replace(" ", "_")
                Select Case Code.ToLower
                    Case Cheats.unlock_all_cos.ToString
                        'Unlock all CO's
                        Hauptmenue.User.LockedCOs.Clear()
                        Hauptmenue.User.LockedCOColors.Clear()
                    Case Else
                        Return False
                End Select
                Return True
            End If
        End If
        Return False
    End Function
    Public Shared Sub AntiCheatingMessage()
        Select Case Zufallszahl(0, 5)
            Case 0
                Write("Cheating is unfair remember me than i kill you!")
            Case 1
                Write("Giving Enemy ∞ Money and ∞ HP for each Unit!")
            Case 2
                Write("Poor Guy your not meant to play this game, if you need to cheat.")
            Case 3
                Write("Checking for cheat Access. No Access only a Gametester is allowed to use cheats.")
            Case 4
                Write("The AI can cheat, too. Believe me!")
            Case 5
                Write("Cheat-Mode detected! Installing Virus on Hard, Middle and Soft Disc. Please wait.!")
        End Select
    End Sub
#End Region
    Shared TextZeilenLocker As New Mutex
    ''' <summary>
    ''' Eintrag 0 ist immer der aelteste
    ''' </summary>
    ''' <remarks></remarks>
    Shared TextZeilen As New List(Of String)
    ''' <summary>
    ''' Wie viele Zeilen Maximal gespeichert werden sollen.
    ''' </summary>
    ''' <remarks></remarks>
    Shared TextZeilenMax As Integer = 50
    ''' <summary>
    ''' Gibt an ob die Konsole gemalt wird oder nicht.
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Aktiv As Boolean = False
    ''' <summary>
    ''' Die Schriftart die fuer unsere Konsole verwendet wird.
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Konsolenschrift As Integer = 0
    ''' <summary>
    ''' Anzeige Frame fuer den Textpointer
    ''' </summary>
    ''' <remarks></remarks>
    Shared Frame As Integer = 0
    ''' <summary>
    ''' Wird der Textpointer gemalt?
    ''' </summary>
    ''' <remarks></remarks>
    Shared TextWriterVisible As Boolean = True
    ''' <summary>
    ''' Wechsel Frame fuer den Textpointer
    ''' </summary>
    ''' <remarks></remarks>
    Const FrameChange As Integer = 10
    ''' <summary>
    ''' Der Backbuffer der Texte die man eingegeben hat.
    ''' </summary>
    ''' <remarks></remarks>
    Shared InputText As New List(Of String)
    ''' <summary>
    ''' Die Laenge des Buffers zum speichern der Eingaben
    ''' </summary>
    ''' <remarks></remarks>
    Const InputBufferLaenge As Integer = 5
    ''' <summary>
    ''' Der letzte Buffer Eintrag der Verarbeitet wurde.
    ''' </summary>
    ''' <remarks></remarks>
    Shared Bufferposition As Integer = 0
    Public Shared TextInputLocker As New Mutex
    ''' <summary>
    ''' Die Textbox die unsere Eingaben auswertet
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared TextInput As TextBox
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared TextInputPosition As Integer = 0
    ''' <summary>
    ''' Die momentane Eingabe
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared MomentanerInputText As String = ""
    ''' <summary>
    ''' Hintergrund Update ausfuehren
    ''' </summary>
    ''' <remarks></remarks>
    Shared BackgroundUpdate As Boolean = False
    ''' <summary>
    ''' Vollbildschirm benutzen?
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Fullscreen As Boolean = False
    ''' <summary>
    ''' Duerfen wir etwas Reinschreiben?
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Input As Boolean = True
    ''' <summary>
    ''' Soll die Konsole im Intro gezeigt werden?
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared KonsolenIntro As Boolean = True
    ''' <summary>
    ''' Should Script-Events shown in the Console?
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared ShowScript As Boolean = False

    ''' <summary>
    ''' Startet die Konsole schreibt einfach ein paar Infos rein!
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Sub IniKonsole()
        Input = False
        Fullscreen = True
        Write("Try to initialize Console with German-Commands")
        Write("Sorry no German-Commands found, because they're not as funny as English one's or something like that!")
        Write("As Revange a funny message")
        CreateFunnyMessage()
    End Sub

    Public Shared Sub CreateFunnyMessage(Optional ByVal Random As Integer = -1)
        If Random < 0 Then
            Random = Zufallszahl(0, 358 + 1)
        End If
        Select Case Random
            Case 0
                Write("No funny games found :( -> Installing some funny Viruses!")
            Case 1
                Write("Remember Bug 1#: The calculation is correct, but why the hell is the output wrong? Maybe the Input is wrong... Maybe")
            Case 2
                Write("No more funny Messages found. Delete your Harddisk instead")
            Case 3
                Write("Creating Enemies with Level 999 above your own Level! So you don't get bored.")
            Case 4
                Write("What? I should work faster? Look at your PC even a snake is faster than your CPU")
            Case 5
                Write("I know this Quest. Nothing can happen! Sorry we couldn't find their corps!")
            Case 6
                Write("1+1=10 ... What you don't understand Binary Stuff -> I can't work with such stupid Users.")
            Case 7
                Write("No good music found. No good videos found. There's nothing funny i can do here.")
            Case 8
                Write("Even if you're eaten by a dragon, you still have two ways out.")
            Case 9
                Write("I know what you did last summer...")
            Case 10
                Write("Positioning GPS satellites... please stand by...")
            Case 11
                Write("The volume goes to eleven!")
            Case 12
                Write("The game will start when it is ready and not before!")
            Case 13
                Write("You are the weakest link, goodbye!")
            Case 14
                Write("/* You are not expected to understand this */")
            Case 15
                Write("Computer load this, computer load that, never a thank you... Rude gamers!")
            Case 16
                Write("Now that's what I call a dead parrot")
            Case 17
                Write("Loading errors, please wait...")
            Case 18
                Write("Reset your char to level 1. There are too many high-level chars online...")
            Case 19
                Write("Your soundcard sucks, disabling sound forever...")
            Case 20
                Write("Relax, it's only ones and zeros!")
            Case 21
                Write("No, this is not a silly message.")
            Case 22
                Write("I still know what you did last summer...")
            Case 23
                Write("Please stand by for an important announcement.")
            Case 24
                Write("Your computer is running... You better go chase it.")
            Case 25
                Write("Drawing beards onto your photographs...")
            Case 26
                Write("What about playing Evil Neighbour! You're the Neighbour. And i'm playing you... You know what!")
            Case 27
                Write("Did you know that by reading this message you have wasted 5 seconds of your life?")
            Case 28
                Write("Press any key... No! Not that one!")
            Case 29
                Write("PI is exactly 3! Because I want to find out how world looks like where PI is exactly 3!")
            Case 30
                Write("Freedom for wolves, ban the shepherds!")
            Case 31
                Write("Your computer is now an official part of my world domination plan. Thank you!")
            Case 32
                Write("There's nothing to see here, go ahead...")
            Case 33
                Write("I don't care what you did last summer!")
            Case 34
                Write("Ohh... I am loading too slowly? Ok, next time you'll load it yourself!")
            Case 35
                Write("Searching for available information on dragons - Connecting to Wikipedia...")
            Case 36
                Write("Warning: Don't try this at home! Why do you ignore this warning?")
            Case 37
                Write("Are we there yet? Are we there yet? Are we there yet? ")
            Case 38
                Write("Oh this game sucks. It really game sucks! Did you know this game sucks!")
            Case 39
                Write("Infiltrated your computer continuing to send your special videos to the CIA! Please Wait!")
            Case 40
                Write("Press Any Key. I can't find the Any Key.")
            Case 41
                Write("Why is it forbidden to use Emergency Exits in Germany? I mean they are called ""Not Exit""")
            Case 42
                Write("Let's play tic-tac-toe instead, I'll be X...")
            Case 43
                Write("Coffee missing. Insert cup and press any key.")
            Case 44
                Write("Clicking the mouse will not make the game load faster!")
            Case 45
                Write("GETRANDOMNUMBER: RETURN 4; // Chosen by fair dice roll, guaranteed to be random")
            Case 46
                Write("Knowledge is a weapon... I intend to be formidably armed.")
            Case 47
                Write("<singing> I can't get no... Bug infection...")
            Case 48
                Write("Press Crtl + Alt + Del now for an IQ test. Sorry IQ is to low to press those Keys.")
            Case 49
                Write("Press any key to continue or other key to quit...")
            Case 50
                Write("You did not call in sick just to play this game, now did you?")
            Case 51
                Write("Reanimating dead monsters... ")
            Case 52
                Write("Backup not found: (A)bort, (R)etry, (G)et a beer. ")
            Case 53
                Write("Nuclear Power Plants are save as long as you don't try to use them to produce energy!")
            Case 54
                Write("Your computer is your friend....Trust the Computer...")
            Case 55
                Write("Counting to Infinity......Please wait...")
            Case 56
                Write("This is not a drill. This is the Apocalypse. Please stay calm and exit the building.")
            Case 57
                Write("Does a Table disappear always you leave a room. Because the modern physic says: it's possible!")
            Case 58
                Write("Its not a bug but a feature.")
            Case 59
                Write("Life? Don't talk to me about life!")
            Case 60
                Write("Stop staring at this message or I will stop loading! ")
            Case 61
                Write("Loading 3D buffer... Not that one!")
            Case 62
                Write("I've calculated your chance of survival, but I don't think you'll like it.")
            Case 63
                Write("No more heroes available. Do you want to play as a monster? (Y/N)")
            Case 64
                Write("Is their any sense in killing all those monsters? I mean the time you are back. They're back, too")
            Case 65
                Write("Do you really want to start the game? Really? Are you really sure?")
            Case 66
                Write("Generating 100 boss monster at starting location... It's only a small challenge!")
            Case 67
                Write("Gaming is about killing time, not killing people...")
            Case 68
                Write("Ordering pizza online... I hope you like anchovies with pineapple!")
            Case 69
                Write("Insert Disc 5... Oh, you don't have a Disc 5? Ok, filling harddisc with garbage...")
            Case 70
                Write("Wasting energy, please wait...")
            Case 71
                Write("Overclocking CPU: 3,0GHz...3,2GHz...3,6GHz... OOPS, I broke your CPU!")
            Case 72
                Write("There is a light at the end of the tunnel, just pray it's not a train.")
            Case 73
                Write("Please do not feed the dragons!")
            Case 74
                Write("Not now! Can't you see I'm busy? Play something else.")
            Case 75
                Write("Would you like to play a game of... world domination?")
            Case 76
                Write("Insert coin to continue...")
            Case 77
                Write("How can this task be delayed when i haven't even started working on it?")
            Case 78
                Write("If the game does not start in five minutes... wait longer! ")
            Case 79
                Write("Randomizing constants...")
            Case 80
                Write("Scroll down the list and choose your favourite silly message. I'm too lazy.")
            Case 81
                Write("There's something written about a chance but I don't trust this game...")
            Case 82
                Write("Checking mouse driver... Checking mouse's driving license...")
            Case 83
                Write("Generating dead undead... Undead dead... uh...")
            Case 84
                Write("Your skill in reading is increased by one point!")
            Case 85
                Write("You'll get an adventure point for reading so much stupid messages. Use this point for improving your Stupidness!")
            Case 86
                Write("Save the Earth... its the only planet with chocolate!")
            Case 87
                Write("Why should we save the world? We didn't find out if we can survive without the world!")
            Case 88
                Write("Operation failed (A)bort, (R)etry, (I)nfluence with large hammer?")
            Case 89
                Write("The past temps us, the present confuses us, and the future frightens us.")
            Case 90
                Write("Checking co2 emissions of your computer... Sorry, it's to high turning off your PC.")
            Case 91
                Write("Sorry, no health potions available. good luck, nevertheless!")
            Case 92
                Write("Are you still in the loading screen? You need a new computer!")
            Case 93
                Write("Deleting all other games on the computer... You'll not need them in the next 5 seconds.")
            Case 94
                Write("How long can you withstand dragon breath again?")
            Case 95
                Write("Do you want to continue? (Y)es, (N)o, (M)aybe")
            Case 96
                Write("Incredible... it's even worse than i thought it would be.")
            Case 97
                Write("It seems that your mouse pointer is trying to move, (C)ancel or (A)llow?")
            Case 98
                Write("Mommy, there's a monster in front of my screen!")
            Case 99
                Write("Load it yourself, you slave driver!")
            Case 100
                Write("You look rather silly staring at this screen...")
            Case 101
                Write("Call 911 for support... ")
            Case 102
                Write("****, can't find this silly message file...")
            Case 103
                Write("Are you sure you can still see the real world as real world?")
            Case 104
                Write("Warning! your computer will self destruct in 5... 4... 3... 2... 1... <kaboom>")
            Case 105
                Write("Don't you have better things to do then reading silly messages?")
            Case 106
                Write("Who wants to live forever? Well... I wouldn't mind giving it a try!")
            Case 107
                Write("Understanding is a three edged sword... our side, their side and the truth!")
            Case 108
                Write("You're part of the game now... ")
            Case 109
                Write("There's a fine line between genius and insanity. I have erased this line.")
            Case 110
                Write("So you want to be evil... Well, i can be evil too. Setting enemy level to 999!")
            Case 111
                Write("Health warning: you have been playing for 12 seconds...")
            Case 112
                Write("Keep clicking until i say stop!")
            Case 113
                Write("Two beer or not two beer...")
            Case 114
                Write("If you have a slow pc, you are able to learn every silly message by heart...")
            Case 115
                Write("Failed to load quests, I will now try to create some on my own...")
            Case 116
                Write("Starting your mp3s... Argh, i can't listen to this anymore, go get some new songs!")
            Case 117
                Write("Press y+m+q+enter+space with one hand to continue.")
            Case 118
                Write("We don't have bugs, we have dragons!")
            Case 119
                Write("This message is intended not to be funny.")
            Case 120
                Write("I don't know what you're talking about, there is no game here...")
            Case 121
                Write("I invented the 'hello world' program!")
            Case 122
                Write("CPU says you should not start those boring office programs anymore.")
            Case 123
                Write("What do you think I am doing? Loading the game?")
            Case 124
                Write("Let's ride some trojan horses... I've found two in the left corner of your harddisc.")
            Case 125
                Write("Killing some bugs, please wait...")
            Case 126
                Write("Loading loadingscreen...")
            Case 127
                Write("Hit any user to continue.")
            Case 128
                Write("This game never has bugs. It just develops random features!")
            Case 129
                Write("You just can't trust developers these days - they got even the silly messages bugged!")
            Case 130
                Write("I don't have a solution, but I admire the problem!")
            Case 131
                Write("There cannot be a crisis today, my schedule is already full.")
            Case 132
                Write("I have a fix opinion, don't confuse me with facts!")
            Case 133
                Write("Remember our first game: The AI can't do that i'm totally convinced. We programmed it a lot stupier.")
            Case 134
                Write("Please wait...Deleting all Items of your character.")
            Case 135
                Write("The best way to create panic is to say: There is no reason to react panically.")
            Case 136
                Write("If you want to continue roll a dice with excatly 21 numbers.")
            Case 137
                Write("Did you feed your Mouse? Because i think it's dead!")
            Case 138
                Write("RPG-Games are boring, they're always about saving the world. Never about conquering or destroying it.")
            Case 139
                Write("If a chance to survive is excactly 1:1000000. Than you'll survive to 100%. Tell me if i'm right by finding it out!")
            Case 140
                Write("Launching Nuclear Rocket in order to protect your character from this monsters. I hope you'll have a high ABC-Ressistance.")
            Case 141
                Write("I prefer a Sword instead of the well known Weapon Knowledge. In a RPG without Magic.")
            Case 142
                Write("An Enum is an Integer is a String is an Enum.")
            Case 143
                Write("I believe i can fly. The Resulst can be seen, now.")
            Case 144
                Write("I always await an Ambush, even when i'm asleep.")
            Case 145
                Write("Computers are more Intelligent than Human. They know X/0 is exactly infinity...")
            Case 146
                Write("I'm not always right! But i'm never wrong!")
            Case 147
                Write("Doing a sneek attack with a ballista is a very clever thing!")
            Case 148
                Write("Transferring all your stuff to the NPC. You wanted it a little bit harder!!!")
            Case 149
                Write("It's so funny to kill them! It should be forbidden! IT'S FORBIDDEN!!!")
            Case 150
                Write("I always wonder how the Fire Wall of a PC looks like. Warning your PC is burning!")
            Case 151
                Write("You've won when the last card has been played or you cheat...")
            Case 152
                Write("Cheat-Mode detected! Installing Virus on Hard, Middle and Soft Disc. Please wait!")
            Case 153
                Write("Dude! Dude!! Dude!!! I like those Dudes. Dude!")
            Case 154
                Write("After a Sandstorm comes Snow and than again a Sandstorm. Never seen this in real life though.")
            Case 155
                Write("I wonder which Game Lash plays in AW DS during Black Bomb Mission. Could it be Advance Wars!")
            Case 156
                Write("I wonder why an APC can give endless Ration eventhough it has run out of fuel.")
            Case 157
                Write("Why do people think Sturm is a robot. Never said in the game. Only Robosturm is a robot.")
            Case 158
                Write("Be friendly with your kids, they choose your home when you are old!")
            Case 159
                Write("Be nice to the ones who smoke.. every cigarette migh be their last.")
            Case 160
                Write("Braindetector activated, calibrating, now searching.........still searching......get a good grip of your mobile....still searching.......no brains found.")
            Case 161
                Write("Did I not see you yesterday at the mall, with a grey jacket? No? O, than it was a rubbish bag after all!")
            Case 162
                Write("What he want, I do not want ... What I want, he does not want ... What we want, is not allowed!")
            Case 163
                Write("An Error has appeared while creating an Error Message.")
            Case 164
                Write("I hate when friends come over and ask, """"Do you have a bathroom?"""" - """"No, we shit outside.""""")
            Case 165
                Write("A PC is only as clever as his User.")
            Case 166
                Write("Access denied, please enter your ID again...")
            Case 167
                Write("As a Computer, I find your faith in technology... amusing!")
            Case 168
                Write("Eek! A mouse! Plug it out! Eek! It's full of bytes!")
            Case 169
                Write("Funny Bugreport #22650: No sound while PC is burning!")
            Case 170
                Write("Loading is booooring...")
            Case 171
                Write("Loading MP3 playlist...")
            Case 172
                Write("Loading silly messages...")
            Case 173
                Write("Loading Sprite #559486753...Please wait!")
            Case 174
                Write("Loading will continue after a short message from our Sponsor.")
            Case 175
                Write("Monday morning Quest: Find my Coffee Mug in the Office!")
            Case 176
                Write("Out of Money error ... Insert new projekt fundings!")
            Case 177
                Write("Please turn off your monitor to continue.")
            Case 178
                Write("Scanning Mail Folder... emty... not even Spam Mail!")
            Case 179
                Write("Searching for Adult Filter...")
            Case 180
                Write("Seaching for saved game... not found. Restarting game...")
            Case 181
                Write("Spiderpig, Spiderpig ...")
            Case 182
                Write("Stop staring at this message or I will stop loading.")
            Case 183
                Write("The... no, A..., no, wait, sorry, that one sounded better in my head.")
            Case 184
                Write("There's something written about a chance but I don´t trust this game...")
            Case 185
                Write("There is a hole... in your mind.")
            Case 186
                Write("There is too much CPU usage in zlib.dll!")
            Case 187
                Write("Unloading silly messages, not silly enough!")
            Case 188
                Write("Updating funny messages...")
            Case 189
                Write("Uplink to ISS etablished, downloading weather forecast...")
            Case 190
                Write("Uploading user fingerprints to NSA computer...")
            Case 191
                Write("Use the mouse, Luke!")
            Case 192
                Write("Video ram too small, switching to grid display...")
            Case 193
                Write("Waiting some time...")
            Case 194
                Write("We're working on the documentation ...")
            Case 195
                Write("Warning! CPU temperature reaching critical... Shutting system down...")
            Case 196
                Write("We apologize for the fault in loading screen. The responsible parties have been sacked.")
            Case 197
                Write("We'll be right back after this commercial break.")
            Case 198
                Write("What’s that behind you?")
            Case 199
                Write("What are you doing? Stop that!")
            Case 200
                Write("When it's done! Got it?")
            Case 201
                Write("When you are leaving, please close the door behind you.")
            Case 202
                Write("Would you like to play a game of...World Domination?")
            Case 203
                Write("Wrong CD Key... this Game will now be locked on this Computer for ever.")
            Case 204
                Write("Yeah but no but yeah but no but yeah but no.")
            Case 205
                Write("You are here: X")
            Case 206
                Write("You are the 1.000.000th visitor! Congratulations! You won a box of tissues - not.")
            Case 207
                Write("You must return to the beginning of the end...")
            Case 208
                Write("You won´t get this package if you can not ID yourself!")
            Case 209
                Write("You really have to find a girlfriend whose name doesn´t end with .jpg!")
            Case 210
                Write("Mysterious Strangers visits: 0")
            Case 211
                Write("I am a cute computer... really!")
            Case 212
                Write("Never seen such a big... never mind...")
            Case 213
                Write("Ladescreen wird mit """"Grosser Hammer"""" gehauen, bitte warten..")
            Case 214
                Write("Deleting all Celine Dion MP3s ...")
            Case 215
                Write("Destroying brain cells... 15 percent... 50 percent... Duuh...")
            Case 216
                Write("Cannot translate silly message into english.")
            Case 217
                Write("Be sure to visit the gift shop on your way out.")
            Case 218
                Write("Checking for 3d buffer ... Wait, not that one!")
            Case 219
                Write("Activating coffee-machine...")
            Case 220
                Write("Check CO2 emissions of your computer...")
            Case 221
                Write("Hehehe! You'll never guess what awaits you here!")
            Case 222
                Write("Bacon is my favourite vegetable...")
            Case 223
                Write("Do not include <STDHEADER.H>, use <STDHEADER> instead!")
            Case 224
                Write("Cannot find Reality.sys… Universe halted.")
            Case 225
                Write("You’re part of the game now...")
            Case 226
                Write("Blocker found! Buddy, open the door!")
            Case 227
                Write("Good. Out of the door. Line on the left. One cross each. Next. Crucifixion?")
            Case 228
                Write("Here I am, brain the size of a planet, and they ask me to load files.")
            Case 229
                Write("Man, what a mess on your harddisc...")
            Case 230
                Write("Never use OS specific API functions directly, use wrapper instead!")
            Case 231
                Write("Hidden DOS secret: Add bugs=off to your config.sys!")
            Case 232
                Write("At some point, we'll have our own options.txt, son. One day...")
            Case 233
                Write("Attention! This game can change your personality into evil...")
            Case 234
                Write("I have the power of... of.. What's my line again?")
            Case 235
                Write("Idea for a messagebox: 'This frame was properly rendered!'")
            Case 236
                Write("Loading Bluescreen...")
            Case 237
                Write("Sponsored by the Umbrella Corporation.")
            Case 238
                Write("Don´t wake me up, I´m working...")
            Case 239
                Write("It´s you again! Don´t you ever sleep?")
            Case 240
                Write("No, this is not a silly message")
            Case 241
                Write("Can I interest anyone in Fruit or Dessert?")
            Case 242
                Write("Your Oma is now Pwned by Studio II!")
            Case 243
                Write("Detected System: Windows 3.11 - Switching Screen Resolution to 320 x 480 Pixels.")
            Case 244
                Write("Hey Buddy! Need a cheap WiFi Cable? Only 100$!")
            Case 245
                Write("Do you like Scary Movies?")
            Case 246
                Write("Out of Money error ... Insert new projekt fundings!")
            Case 247
                Write("My missus says that a spline is the mathmatical backbone of the game.")
            Case 248
                Write("Two wrongs don't make a right, but three rights make a left!")
            Case 249
                Write("I'm sensing a soul in search of answers...")
            Case 250
                Write("Only silly coders need to optimize their code!")
            Case 251
                Write("Uplink to ISS etablished, downloading weather forecast...")
            Case 252
                Write("Good luck everyone - hope to see you again in the future!")
            Case 253
                Write("A book can also be, a hat...")
            Case 254
                Write("West of house, there is a small mailbox here. Exits are east and south.")
            Case 255
                Write("Don't create multiple postings, use the edit button!")
            Case 256
                Write("Do not disturb, system is disturbed already!")
            Case 257
                Write("Don't push me. I'm doing my best, but your machine... tztztz...")
            Case 258
                Write("Back again? Ha, you don't learn, do you?")
            Case 259
                Write("... go to spriegel the schmitzel wertzen or something to that effect!")
            Case 260
                Write("...Boldly going, where no one has ever gone before. At Least not recently.")
            Case 261
                Write("Help! Your Keyboard is stuckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk... ")
            Case 262
                Write("General Failure's fault. Not yours.")
            Case 263
                Write("Deleting previously saved games...")
            Case 264
                Write("Searching for illegal Software ... just kidding!")
            Case 265
                Write("Dude, where's my car?")
            Case 266
                Write("Do you really want to start the game? Really?")
            Case 267
                Write("Due to lack of system resources, entering slide-show mode...")
            Case 268
                Write("Cheater detected. Loading bunnies...")
            Case 269
                Write("Even if you die healthy, your dead.")
            Case 270
                Write("#1 The Game doesn't work! Did you install the Requirements (Netframework 3.5).")
            Case 271
                Write("#2 The Game crushes after pressing a Button! -> Do you have DirectX 9?")
            Case 272
                Write("3# Those users can't read a simple Textfile. -> Unloading")
            Case 273
                Write("Real Messages: Debugger doesn't work properly! Do you wish do Debug the Debugger with the Debugger?")
            Case 274
                Write("Real Messages: Error Do you want to save your stuff or terminate without it? (Y)es ; (N)o.")
            Case 275
                Write("Remember Bug 4: An Undead OS Soldier is still alive with -5 HP.")
            Case 276
                Write("We're going to be killed! Fascinating.")
            Case 277
                Write("Weather Forcast: Your Turns Snow and Sandstorm. Enemy Turns Sun")
            Case 278
                Write("Setting Volcan Targets to all your Troops. Please wait...")
            Case 279
                Write("How do factories produce endless Infatries? They're came out of (a) Black Hole.")
            Case 280
                Write("Those Dudes are eating fuel?")
            Case 281
                Write("Changing the Owner of all your HQ's to the AI.")
            Case 282
                Write("HOW MAY I SERVE YOU, INFERIOR BEING?")
            Case 283
                Write("Those APC's are great. They can supply flying Units.")
            Case 284
                Write("Wait! Black Boat changes into Black Flying Boat in Order to repair your Stealthfighter.")
            Case 285
                Write("Transferring your Income to a Swiss Bank. You won't have access to it during a battle. But hey you pay less taxes.")
            Case 286
                Write("Didn't find a Dice for GETRANDOMNUMBER(). Please insert one into your CD Player.")
            Case 287
                Write("Always doing the same is boring! Let's find out how a burning PC looks like!")
            Case 288
                Write("The World is a plate and is carried by a Turtle on which stands three elephants. Everything else is wrong.")
            Case 289
                Write("Nice PC! Gets even more nice after i connected you to my botnet.")
            Case 290
                Write("You don't have facebook??? Now, when you're officialy dead-> Dead people can't play! Stop loading...")
            Case 291
                Write("Does a falling tree makes no Sound if there is nobody to here it fall?")
            Case 292
                Write("Do you wish do spent all your money to the Project Owner? (Y)es ; No (disabled).")
            Case 293
                Write("Sturm is dead! It live Sturm.")
            Case 294
                Write("It should be fair. God go away with your human feelings. It's of course unfair.")
            Case 295
                Write("""Ha finally i've got the last word.""......""Nearly the last.""")
            Case 296
                Write("The part where you all shut up happens now.")
            Case 297
                Write("My motto is that there are far too many women in the world to waste time with men.")
            Case 298
                Write("You think i'm not funny? I can be not funny...")
            Case 299
                Write("The bigger they are, the harder they fall!")
            Case 300
                Write("Computers are useless.  They can only give you answers.")
            Case 301
                Write("Computers are like bikinis. They save people a lot of guesswork.")
            Case 302
                Write("We have computers, and we may have other weapons of mass destruction.")
            Case 303
                Write("That’s what’s cool about working with computers.  They don’t argue, they remember everything, and they don’t drink all your beer.")
            Case 304
                Write("If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside.")
            Case 305
                Write("I’ve noticed lately that the paranoid fear of computers becoming intelligent and taking over the world has almost entirely disappeared from the common culture.  Near as I can tell, this coincides with the release of MS-DOS.")
            Case 306
                Write("The question of whether computers can think is like the question of whether submarines can swim.")
            Case 307
                Write("It’s ridiculous to live 100 years and only be able to remember 30 million bytes.  You know, less than a compact disc.  The human condition is really becoming more obsolete every minute.")
            Case 308
                Write("Never trust a computer you can’t throw out a window.")
            Case 309
                Write("Hardware: The parts of a computer system that can be kicked.")
            Case 310
                Write("Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves.")
            Case 311
                Write("I’ve finally learned what ‘upward compatible’ means.  It means we get to keep all our old mistakes.")
            Case 312
                Write("The Internet?  Is that thing still around?")
            Case 313
                Write("Any fool can use a computer.  Many do.")
            Case 314
                Write("There are only two industries that refer to their customers as ‘users’.")
            Case 315
                Write("Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots.  So far the Universe is winning.")
            Case 316
                Write("The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.")
            Case 317
                Write("That’s the thing about people who think they hate computers.  What they really hate is lousy programmers.")
            Case 318
                Write("Don’t worry if it doesn’t work right.  If everything did, you’d be out of a job.")
            Case 319
                Write("Measuring programming progress by lines of code is like measuring aircraft building progress by weight.")
            Case 320
                Write("Writing code has a place in the human hierarchy worth somewhere above grave robbing and beneath managing.")
            Case 321
                Write("First learn computer science and all the theory.  Next develop a programming style.  Then forget all that and just hack.")
            Case 322
                Write("First, solve the problem. Then, write the code.")
            Case 323
                Write("The best thing about a boolean is even if you are wrong, you are only off by a bit.")
            Case 324
                Write("Should array indices start at 0 or 1?  My compromise of 0.5 was rejected without, I thought, proper consideration.")
            Case 325
                Write("There are only two kinds of programming languages: those people always bitch about and those nobody uses.")
            Case 326
                Write("I think Microsoft named .Net so it wouldn’t show up in a Unix directory listing.")
            Case 327
                Write("There is no programming language–no matter how structured–that will prevent programmers from making bad programs.")
            Case 328
                Write("Fifty years of programming language research, and we end up with C++?")
            Case 329
                Write("In C++ it’s harder to shoot yourself in the foot, but when you do, you blow off your whole leg.")
            Case 330
                Write("One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.")
            Case 331
                Write("Fine, Java MIGHT be a good example of what a programming language should be like.  But Java applications are good examples of what applications SHOULDN’T be like.")
            Case 332
                Write("If Java had true garbage collection, most programs would delete themselves upon execution.")
            Case 333
                Write("Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.")
            Case 334
                Write("The first 90% of the code accounts for the first 10% of the development time.  The remaining 10% of the code accounts for the other 90% of the development time.")
            Case 335
                Write("If debugging is the process of removing bugs, then programming must be the process of putting them in.")
            Case 336
                Write("I don’t care if it works on your machine!  We are not shipping your machine!")
            Case 337
                Write("There are two ways to write error-free programs; only the third one works.")
            Case 338
                Write("You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time.")
            Case 339
                Write("Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.")
            Case 340
                Write("Windows NT addresses 2 Gigabytes of RAM, which is more than any application will ever need.")
            Case 341
                Write("Keyboard not found. Press < F1 > to RESUME.")
            Case 342
                Write("Any sufficiently advanced bug is indistinguishable from a feature.")
            Case 343
                Write("Beware of bugs in the above code; I have only proved it correct, not tried it.")
            Case 344
                Write("bug, n: An elusive creature living in a program that makes it incorrect. The activity of ""debugging"", or removing bugs from a program, ends when people get tired of doing it, not when the bugs are removed.")
            Case 345
                Write("Don't get suckered in by the comments— they can be terribly misleading. Debug only code")
            Case 346
                Write("If the code and the comments disagree, then both are probably wrong.")
            Case 347
                Write("Once you're done writing the code, never open it again unless you want to see how uncomprehensible and utterly ridiculous it really is.")
            Case 348
                Write("The generation of random numbers is too important to be left to chance.")
            Case 349
                Write("The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.")
            Case 350
                Write("When I wrote this, only God and I understood what I was doing...Now, God only knows")
            Case 351
                Write("Sometimes I believe compiler ignores all my comments")
            Case 352
                Write("<!-- Here be dragons  -->")
            Case 353
                Write("You don't need luck. You need enough firepower.")
            Case 354
                Write("Your Infantries get sick. They won't fight until tomorrow.")
            Case 355
                Write("Hae! Hae! I've got a nice idea. What about transferring all your income to the AI.")
            Case 356 'This is a self cloryfing Message please do not ignore it.
                Write("Pray to the great Robosturm! Robosturm is our Master.")
            Case 357
                Write("--> Here was your Army before Sturm... Well, you know what!")
            Case 358
                Write("This Game isn't about peace so ""make war""")
            Case 359
                Write("Computers are useless.  They can only give you answers.")
            Case 360
                Write("I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.")
            Case 361
                Write("The gap between theory and practice is not as wide in theory as it is in practice.")
            Case 362
                Write("There are two major products that come out of Berkeley: LSD and UNIX. We don’t believe this to be a coincidence.")
            Case 363
                Write("Debugging is twice as hard as writing the code in the first place.  Therefore, if you write the code as cleverly as possible, you are–by definition–not smart enough to debug it.")
            Case 364
                Write("If at first you don’t succeed, call it version 1.0")
            Case 365
                Write("Rules of Optimization: Rule(1) : Don() 't do it.    Rule 2 (for experts only): Don't do it yet.")
            Case 366
                Write("Programming can be fun, so can cryptography; however they should not be combined.")
            Case 367
                Write("Computers are good at following instructions, but not at reading your mind.")
            Case 368
                Write("I just saw my life flash before my eyes and all I could see was a close tag…")
            Case 369
                Write("Java: write once, debug everywhere.")
            Case 370
                Write("All methodologies are based on fear.")
            Case 371
                Write("Real programmers don't document. If it was hard to write, it should be hard to understand.")
            Case 372
                Write("If we knew what we were doing, it wouldn't be called research, would it?")
            Case 373
                Write("There are two kind of sysadmins: Paranoids and Losers.")
            Case 374
                Write("We all know Linux is great... it does infinite loops in 5 seconds.")
            Case 375
                Write("Comments lie. Code doesn't.")
			Case 376
                Write("The Code is the Comment or believe in god.")
				
            Case Else
                Write("Exceed Funny Message File. Creating some new one's.")
        End Select
    End Sub


    ''' <summary>
    ''' Schreibt eine oder mehrere Zeilen in die Konsole
    ''' </summary>
    ''' <param name="Text"></param>
    ''' <remarks></remarks>
    Public Shared Sub Write(ByVal Text As String)
        'Sollen wir alles auch in die Windowskonsole schreiben?
        If DataSettings.WindowsKonsolenausgabe Then
            Console.WriteLine(Text)
        End If

        TextZeilenLocker.Lock()
        TextZeilen.Add(Text)
        While TextZeilen.Count > TextZeilenMax
            TextZeilen.RemoveRange(0, TextZeilen.Count - TextZeilenMax)
        End While
        TextZeilenLocker.Unlock()
    End Sub
    ''' <summary>
    ''' Schreibt eine oder mehrere Zeilen in die Konsole
    ''' </summary>
    ''' <param name="Texte"></param>
    ''' <param name="Rev">wenn True, dann ist die oberste Zeile, der erste Eintrag im Array, die neuese Nachricht.</param>
    ''' <remarks></remarks>
    Public Shared Sub Write(ByVal Texte() As String, Optional ByVal Rev As Boolean = True)
        If Rev Then
            For i = Texte.Length - 1 To 0 Step -1
                Write(Texte(i))
            Next
        Else
            For i = 0 To Texte.Length - 1
                Write(Texte(i))
            Next
        End If
    End Sub
    ''' <summary>
    ''' User(Benutzer) Eingabe!!!
    ''' Ja hier wird man benutzt.
    ''' Schlimme Dinge passieren hier!
    ''' </summary>
    ''' <param name="Text"></param>
    ''' <remarks></remarks>
    Public Shared Sub WriteText(ByVal Text As String)
        'Eingabe auf nichts setzen...
        MomentanerInputText = ""
        TextInputPosition = 0

        'Text in Anzeige uebergeben
        Write(Text)
        'buffer aktualiesieren
        InputText.Add(Text)
        If InputText.Count > InputBufferLaenge Then InputText.RemoveAt(0)
        Bufferposition = -1

        'Eingabe auswerten...
        'Ist es ein Cheat?

        'Ein Normaler Befehl?
        If Text.EndsWith("\?") Then
            Dim Order As String
            Text = Text.Replace("\?", "")
            If Text.Contains("(") Then
                Order = Text.Substring(0, Text.IndexOf("("))
            Else
                Order = Text
            End If

            Write("The Help for this Funcion is:")
            'Hier wird die Hilfe zu einem Befehl ausgefuehrt.
            ShowHelp(Order)
        Else

            Dim Parameter As String() = {}
            Dim Order As String = GetOrder(Text, Parameter)

            If Cheat(Order, Parameter) Then
                Exit Sub
            End If

            'Hier steht die Ausfuehrung eines Befehls
            DoOrder(Order, Parameter)
        End If
    End Sub
    Public Shared Function GetOrder(ByVal Text As String, ByRef Parameter() As String) As String
        Dim Order As String
        If Text.Contains("(") Then
            Order = Text.Substring(0, Text.IndexOf("("))
            If Not Text.EndsWith(")") Then Text += ")"
            Text = Text.Remove(Text.LastIndexOf(")"))
            Parameter = Text.Remove(0, Text.IndexOf("(") + 1).Split(",")
        Else
            Order = Text
            Parameter = New String() {""}
        End If
        For I = 0 To Parameter.Length - 1
            Parameter(I) = Parameter(I).Trim()
        Next
        Return Order
    End Function
    ''' <summary>
    ''' Zeigt die Hilfe fuer einen Befehl an.
    ''' </summary>
    ''' <param name="Order"></param>
    ''' <remarks></remarks>
    Private Shared Sub ShowHelp(ByVal Order As String)
        Select Case Order.ToLower
            Case KonsolenBefehle.convertpictures.ToString
                Write("ConvertPictures(String: Folder ; Colortable) Creates copy images with this Colortable.")
            Case KonsolenBefehle.splitpicture.ToString
                Write("SplitPicture(String: File ; Integer: Size ; Optional: Integer: Height) Splits a Picture into several Pictures with the Size.")
            Case KonsolenBefehle.quit.ToString
                Write("Quit(): Close the Game.")
            Case "exit"
                Write("Exit(): Close the Console.")
            Case KonsolenBefehle.funnymessage.ToString
                Write("FunnyMessage(Optional: Integer: Message) Prints out a Random Funny Message!")
            Case KonsolenBefehle.help.ToString
                Write("Help(String: Begin of Order) Prints out all Commands with this beginning! May exceed Console Resolution!")
            Case KonsolenBefehle.getfps.ToString
                Write("GetFPS(): Shows the actual FPS.")
            Case KonsolenBefehle.changewindowresolution.ToString
                Write("ChangeResolution(Integer: Width, Height) Changes the Window Resolution (only in Windowed-Mode).")
            Case KonsolenBefehle.changewindowstate.ToString
                Write("ChangeWindowState() Switchs between Window-Mode and Fullscreen-Mode!")
            Case KonsolenBefehle.changeconsoleresolution.ToString
                Write("ChangeConsoleResolution() Changes the Resolution of the Console!")
            Case KonsolenBefehle.showgameorders.ToString
                Write("ShowGameOrders() En\Disables showing the Orders you to in the Console during a Game.")
            Case KonsolenBefehle.usewindowsconsole.ToString
                Write("UseWindowsConsole() En\Disables Sending all Messages to the Windows Console.")
            Case KonsolenBefehle.commanderwarsisbest.ToString.ToLower
                Write("CommanderWarsIsBest(Boolean: Activate) En\Disables cheating during the Game.")
            Case KonsolenBefehle.changedebugmode.ToString
                Write("ChangeDebugMode() En\Disables the Debug-Mode no major stuff will happen.")
            Case KonsolenBefehle.battleanimations.ToString
                Write("Battleanimations(Integer: Battleanimation) Set the Battleanimations in the Game.")
            Case KonsolenBefehle.checkscript.ToString
                Write("CheckScript() Checks if we have a Script loaded!")
            Case KonsolenBefehle.netprotocol.ToString
                Write("NetProtocol() Dis\Allows you to read the Net-Input!")
            Case KonsolenBefehle.speechrecoqassembly.ToString
                Write("SpeechRecoqAssembly() Checks if System.Speech is installed on your PC.")
            Case KonsolenBefehle.getvalue.ToString
                Write("GetValue(String: ValueID) Prints out the Value of a specifiv Setting.")
            Case KonsolenBefehle.aibreak.ToString
                Write("AIBreak() Forces the AI to interrupt moves until AIContinue is called.")
            Case KonsolenBefehle.aicontinue.ToString
                Write("AIContinue() Forces the AI to continue moves after AIBreak was called.")
            Case KonsolenBefehle.terminategame.ToString
                Write("TerminateGame() Quits the current running Game.")
            Case KonsolenBefehle.launchscript.ToString
                Write("LaunchScript(Integer: Scriptnumber) Launches the Script immediatly.")
            Case KonsolenBefehle.createmasks.ToString
                Write("CreateMasks(String: Path ; Optional Boolean: Subdirectories) Creates the Image Mask for all Pictures.")
            Case KonsolenBefehle.changeiniai.ToString
                Write("ChangeIniAI(String: Folder Integer:AI Optional Integer: OldAI) Overwrites all AI's in the Ini with the new AI.")
            Case KonsolenBefehle.changemapai.ToString
                Write("ChangeIniAI(String: Folder ; Boolean: SubFolder ; Integer:AI_Player_1 ; Integer: AI_Other_Player) Overwrites all AI's in the Map with the new AI's.")
            Case KonsolenBefehle.changecursor
                Write("ChangeCursor() Decides wether the Windowscursor is shown or not.")
            Case KonsolenBefehle.testnetwork.ToString
                Write("TestNetwork() Checks the Network function for working.")
            Case KonsolenBefehle.importtxtmaps.ToString
                Write("ImportTxtMaps(String: Folder) Imports all .Txt Maps of CoW.")
            Case KonsolenBefehle.exporttxtmaps.ToString
                Write("ExportTxtMaps(String: Folder) Exports all .Txt Maps of CoW.")
            Case KonsolenBefehle.updatedirectoryandfiles.ToString
                Write("ExportTxtMaps(String: Folder) Updates all Files and Directories and replaces typical German Letters with English Letters.")
            Case KonsolenBefehle.updatefiles.ToString
                Write("UpdateFiles(String: Directory) Updates all Files in the Directory from Older Version to the current one. (Use only when told by the Developpers)!!!")
            Case KonsolenBefehle.createcolortables.ToString
                Write("CreateColorTables(String: Folder ; Integer Sourcesheet) Creates a Color Table for the CO-Sheets in this folder.")
            Case KonsolenBefehle.updatemaps.ToString
                Write("UpdateMaps(String: Folder ; Optional: Boolean: Backup=False) Updates all Maps into the new Mapformat.")
            Case KonsolenBefehle.updatemap.ToString
                Write("UpdateMap(String: File ; Optional: Boolean: Backup=False) Updates all Map into the new Mapformat.")
            Case KonsolenBefehle.saveasoldmap.ToString
                Write("SaveAsOldMap(String: File) Saves a Map in the old Mapformat of CoW.")
            Case KonsolenBefehle.viewmembers.ToString
                Write("ViewMembers() Shows all Info over the Player in the Lobby.")
            Case Else
                If CheatMode Then
                    Write("Cheats won't be published!")
                Else
                    Write("Unknown Command")
                End If
        End Select
    End Sub
    ''' <summary>
    ''' Fuehrt einen Befehl der Konsole aus.
    ''' </summary>
    ''' <param name="Order"></param>
    ''' <param name="Parameter"></param>
    ''' <remarks></remarks>
    Private Shared Sub DoOrder(ByVal Order As String, ByVal Parameter() As String)
        Try
            Select Case Order.ToLower
                Case KonsolenBefehle.showaidata.ToString
                    'Force the Game to show some AI-Dependend Calculations on the Map
                    If Objektverwalter.Spielfeld IsNot Nothing Then
                        Objektverwalter.Spielfeld.ShowAIData = Not Objektverwalter.Spielfeld.ShowAIData
                    End If
                Case KonsolenBefehle.change_strategy_loading.ToString
                    Database.Text_Based_Strategy = Not Database.Text_Based_Strategy
                Case KonsolenBefehle.get_ai_strategies.ToString
                    If Objektverwalter.Spielfeld IsNot Nothing Then
                        For I = 1 To Objektverwalter.Spielfeld.Spieler.Length - 1
                            If Objektverwalter.Spielfeld.Spieler(I).KIStufe = ObjektSpieler.KIStufen.Schwer Then
                                Konsole.Write("Player:" + I.ToString)
                                For I2 = 0 To CType(Objektverwalter.Spielfeld.Spieler(I).AI_Class, AI_Heavy).AIDatabase.PlayerDatas.Count - 1
                                    If I - 1 <> I2 Then
                                        Konsole.Write("VS. Player " + (I2 + 1).ToString + ":" + CType(Objektverwalter.Spielfeld.Spieler(I).AI_Class, AI_Heavy).AIDatabase.PlayerDatas(I2).AI_Strategy.Current_Strategy.ToString)
                                    End If
                                Next
                            End If
                        Next
                    End If
                Case KonsolenBefehle.testnetwork.ToString
                    NetworkTest.NetworkTest()
                Case KonsolenBefehle.speechrecoqassembly.ToString
                    Konsole.Write("System.Speech Assembly: " + (Not Hauptmenue.NoAssemblyFound).ToString)
                Case KonsolenBefehle.quit.ToString
                    Hauptmenue.MainMenue.Close()
                Case "exit"
                    AendereKonsolenStatus()
                Case KonsolenBefehle.funnymessage.ToString
                    If Parameter.Length > 0 Then
                        If IsNumeric(Parameter(0)) Then
                            CreateFunnyMessage(Parameter(0))
                        Else
                            CreateFunnyMessage()
                        End If
                    Else
                        CreateFunnyMessage()
                    End If
                Case KonsolenBefehle.changeconsoleresolution.ToString
                    Fullscreen = Not Fullscreen
                Case KonsolenBefehle.help.ToString
                    If Parameter.Length > 0 Then
                        Suchmaske(Parameter(0))
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.splitpicture.ToString
                    If Parameter.Length > 1 Then
                        If IsNumeric(Parameter(1)) Then
                            If Parameter.Length > 2 Then
                                If IsNumeric(Parameter(2)) Then
                                    Hauptmenue.SplitPicture(Parameter(0), Parameter(1), Parameter(2))
                                Else
                                    Hauptmenue.SplitPicture(Parameter(0), Parameter(1))
                                End If
                            Else
                                Hauptmenue.SplitPicture(Parameter(0), Parameter(1))
                            End If

                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.convertpictures.ToString
                    If Parameter.Length > 1 Then
                        Hauptmenue.ConvertPictures(Parameter(0), Parameter(1))
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.launchscript.ToString
                    If Parameter.Length > 0 Then
                        If IsNumeric(Parameter(0)) Then
                            If ObjektScript.Scripts.Length > 0 Then
                                Dim Script As Integer = Parameter(0)
                                If Script < ObjektScript.Scripts.Length Then
                                    ObjektScript.Scripts(Script).LaunchScript()
                                Else
                                    Write("Script not found.")
                                End If
                            Else
                                Write("Script not found.")
                            End If
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.getfps.ToString
                    Write("FPS: " + Hauptmenue.FPS.ToString)
                Case KonsolenBefehle.changewindowstate.ToString
                    Grafikengine.ChangeWindowState = True
                Case KonsolenBefehle.changewindowresolution.ToString
                    If Hauptmenue.MainMenue.FormBorderStyle = FormBorderStyle.Sizable Then
                        If Parameter.Length > 2 Then
                            If IsNumeric(Parameter(0)) Then
                                If IsNumeric(Parameter(1)) Then
                                    Hauptmenue.MainMenue.Bounds = New Rectangle(Hauptmenue.MainMenue.Location, New Point(Parameter(0), Parameter(1)))
                                Else
                                    Write("Unknown Arguments")
                                End If
                            Else
                                Write("Unknown Arguments")
                            End If
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Only in Window-Mode avaible!")
                    End If
                Case KonsolenBefehle.usewindowsconsole.ToString
                    DataSettings.WindowsKonsolenausgabe = Not DataSettings.WindowsKonsolenausgabe
                    DataSettings.MySettingsIniSave()
                Case KonsolenBefehle.showgameorders.ToString
                    DataSettings.KonsolenSpielBefehle = Not DataSettings.KonsolenSpielBefehle
                    DataSettings.MySettingsIniSave()
                Case KonsolenBefehle.commanderwarsisbest.ToString.ToLower
                    If Hauptmenue.Connection.Connected Then
                        CheatMode = False
                    Else
                        If Parameter.Length > 0 Then
                            If Parameter(0) <> "" Then
                                If CBool(Parameter(0)) = True Then
                                    CheatMode = True
                                    AntiCheatingMessage()
                                Else
                                    CheatMode = False
                                End If
                            End If
                        End If

                    End If
                Case KonsolenBefehle.changedebugmode.ToString
                    'Schaltet in den Debug-Mouds um
                    Hauptmenue.Debbuging = Not Hauptmenue.Debbuging
                Case KonsolenBefehle.battleanimations.ToString
                    If Parameter.Length > 0 Then
                        If IsNumeric(Parameter(0)) Then
                            DataSettings.KampfAnimationen = CInt(Parameter(0))
                        Else
                            DataSettings.KampfAnimationen = KampfanimationsTypen.Keine
                        End If
                    Else
                        DataSettings.KampfAnimationen = KampfanimationsTypen.Keine
                    End If
                    If DataSettings.KampfAnimationen > KampfanimationsTypen.Keine Then
                        DataSettings.KampfAnimationen = KampfanimationsTypen.Keine
                    End If
                    DataSettings.MySettingsIniSave()
                Case KonsolenBefehle.netprotocol.ToString
                    Hauptmenue.NetzProtokoll = Not Hauptmenue.NetzProtokoll
                Case KonsolenBefehle.checkscript.ToString
                    If ObjektScript.Scripts IsNot Nothing Then
                        If ObjektScript.Scripts.Length > 0 Then
                            Write("Found Scripts")
                            Write("Number of Scripts: " + ObjektScript.Scripts.Length.ToString)
                            ShowScript = True
                        Else
                            ShowScript = False
                            Write("No Scripts found")
                        End If
                    Else
                        Write("No Scripts found")
                    End If
                Case KonsolenBefehle.getvalue.ToString
                    If Parameter.Length > 0 Then
                        Try
                            Dim Sett As Settings = [Enum].Parse(Settings.Language.GetType, Parameter(0))
                            PrintIniValue(Sett)
                        Catch
                            Write("Unknown Arguments")
                        End Try
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.aibreak.ToString
                    If Objektverwalter.Spielfeld IsNot Nothing Then
                        If Objektverwalter.Spielfeld.CurrentAI IsNot Nothing Then
                            Objektverwalter.Spielfeld.CurrentAI.KIKonsolenPause = True
                        Else
                            Write("No AI found!")
                        End If
                    Else
                        Write("No Game found!")
                    End If
                Case KonsolenBefehle.aicontinue.ToString
                    If Objektverwalter.Spielfeld IsNot Nothing Then
                        If Objektverwalter.Spielfeld.CurrentAI IsNot Nothing Then
                            Objektverwalter.Spielfeld.CurrentAI.KIKonsolenPause = False
                        Else
                            Write("No AI found!")
                        End If
                    Else
                        Write("No Game found!")
                    End If
                Case KonsolenBefehle.terminategame.ToString
                    If TypeOf Objektverwalter.Menue Is ObjektSpielMenue Then
                        Dim Menue As ObjektSpielMenue = Objektverwalter.Menue
                        Menue.Dispose()
                    End If
                Case KonsolenBefehle.createmasks.ToString
                    If Parameter.Length > 0 Then
                        If Parameter.Length >= 2 Then
                            If CBool(Parameter(1)) = True Then
                                Hauptmenue.CreateAllMasksSubDirectory(Parameter(0))
                            Else
                                Hauptmenue.CreateAllMasks(Parameter(0))
                            End If
                        Else
                            Hauptmenue.CreateAllMasksSubDirectory(Parameter(0))
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.changeiniai.ToString
                    If Parameter.Length = 2 Then
                        Dim P As String = DataSettings.Resourcenpfad + Parameter(0)
                        Hauptmenue.UpdateAIinIni(P, Parameter(1))
                    ElseIf Parameter.Length >= 3 Then
                        Dim P As String = DataSettings.Resourcenpfad + Parameter(0)
                        Hauptmenue.UpdateAIinIni(P, Parameter(1), Parameter(2))
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.changemapai.ToString
                    If Parameter.Length >= 4 Then
                        If IsNumeric(Parameter(2)) And IsNumeric(Parameter(3)) Then
                            Dim AINumber As Integer = [Enum].GetNames(ObjektSpieler.KIStufen.Einfach.GetType).Length - 2
                            If CInt(Parameter(2)) < AINumber And CInt(Parameter(3)) < AINumber Then
                                If IsBoolean(Parameter(1)) Then
                                    Hauptmenue.UpdateAIMaps(Parameter(0), Parameter(1), Parameter(2), Parameter(3))
                                Else
                                    Write("Unknown Arguments")
                                End If
                            Else
                                Write("Unknown Arguments")
                            End If
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.changecursor.ToString
                    DataSettings.HideCursor = Not DataSettings.HideCursor
                    DataSettings.MySettingsIniSave()
                Case KonsolenBefehle.importtxtmaps.ToString
                    If Parameter.Length > 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith("\") Then F += "\"
                        If My.Computer.FileSystem.DirectoryExists(F) Then
                            Hauptmenue.ImportAllTxtMaps(F, F + "Output", FileIO.SearchOption.SearchAllSubDirectories)
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.exporttxtmaps.ToString
                    If Parameter.Length > 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith("\") Then F += "\"
                        If My.Computer.FileSystem.DirectoryExists(F) Then
                            Hauptmenue.ExportAllTxtMaps(F, F + "Output", FileIO.SearchOption.SearchAllSubDirectories)
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.updatedirectoryandfiles.ToString
                    If Parameter.Length > 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith("\") Then F += "\"
                        If My.Computer.FileSystem.DirectoryExists(F) Then
                            Hauptmenue.ChangeLetter(F)
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.updatefiles.ToString
                    If Parameter.Length > 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith("\") Then F += "\"
                        If My.Computer.FileSystem.DirectoryExists(F) Then
                            Hauptmenue.ChangeLetter(F)
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.createcolortables.ToString
                    If Parameter.Length > 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith("\") Then F += "\"
                        If My.Computer.FileSystem.DirectoryExists(F) Then
                            Hauptmenue.createColorTables(F, Parameter(1))
                        Else
                            Write("Unknown Arguments")
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.updatemaps.ToString
                    If Parameter.Length > 0 Then
                        Dim F As String = Parameter(0)
                        If F.Length > 0 Then
                            If Not F.EndsWith("\") Then F += "\"
                            Dim Update As Boolean = False
                            If Parameter.Length > 1 Then
                                Update = CBool(Parameter(1))
                            End If
                            Hauptmenue.UpdateMaps(F, FileIO.SearchOption.SearchAllSubDirectories, Update)
                        Else
                            Hauptmenue.UpdateMaps(DataSettings.Resourcenpfad + "Maps\", FileIO.SearchOption.SearchAllSubDirectories, False)
                        End If
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.updatemap.ToString
                    If Parameter.Length >= 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith("\") Then F += "\"
                        Dim Update As Boolean = False
                        If Parameter.Length >= 1 Then
                            Update = CBool(Parameter(1))
                        End If
                        Hauptmenue.UpdateMap(F, Update)
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.saveasoldmap.ToString
                    If Parameter.Length >= 0 Then
                        Dim F As String = Parameter(0)
                        If Not F.EndsWith(".map") Then F += ".map"
                        Hauptmenue.Speichern(F, , , True, True)
                    Else
                        Write("Unknown Arguments")
                    End If
                Case KonsolenBefehle.viewmembers.ToString
                    If Hauptmenue.Lobby IsNot Nothing Then
                        For I = 0 To BaseLobby.Members.Count - 1
                            Write(BaseLobby.Members(I).ToString)
                        Next
                    End If
                Case Else
                    Write("Unknown Command")
            End Select
        Catch
            Write("Unknown Arguments")
        End Try
    End Sub
    ''' <summary>
    ''' Die Suchmaske fuer den Hilfebefehl.
    ''' </summary>
    ''' <param name="Input"></param>
    ''' <remarks></remarks>
    Private Shared Sub Suchmaske(ByVal Input As String)
        Dim Befehle As List(Of String) = [Enum].GetNames(KonsolenBefehle.funnymessage.GetType).ToList
        Befehle.Add("exit")
        Dim I2 As Integer = 0
        For I = 0 To Befehle.Count - 1
            If Befehle(I).ToLower.StartsWith(Input.ToLower) Then
                I2 += 1
                Write(I2.ToString + ": " + Befehle(I))
            End If
        Next
    End Sub
    ''' <summary>
    ''' Konsole ein und ausblenden
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Sub AendereKonsolenStatus()
        Aktiv = Not Aktiv
        TextInput.Visible = True
        If Aktiv Then
            TextInput.Focus()
            Hauptmenue.MainMenue.Focus()
            TextInput.Focus()
            TextInput.ClearUndo()
            TextInput.Text = ""
            MomentanerInputText = ""
            TextInputPosition = 0
        Else
            MomentanerInputText = ""
            TextInput.Text = ""
            TextInputPosition = 0
            'Fokus abgeben.
            Hauptmenue.MainMenue.Focus()
        End If
    End Sub
    ''' <summary>
    ''' Tastatur Eingabe auswerten.
    ''' </summary>
    ''' <param name="e"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function KeyDown(ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
        If Not TextInput.Focused Then Aktiv = False
        If Aktiv Then
            Select Case e.KeyCode
                Case Keys.Enter 'Eingabe uebergeben
                    WriteText(MomentanerInputText)
                Case DataSettings.AktivKonsole 'Konsole ausblenden oder anzeigen
                    AendereKonsolenStatus()
                Case Keys.Up 'Buffer durchwaehlen
                    Bufferposition -= 1
                    If Bufferposition < -1 Then Bufferposition = InputText.Count - 1
                    If Bufferposition < 0 Then
                        MomentanerInputText = ""
                    Else
                        MomentanerInputText = InputText(Bufferposition)
                    End If
                    TextInputPosition = MomentanerInputText.Length
                Case Keys.Down 'Buffer durchwaehlen
                    Bufferposition += 1
                    If Bufferposition > InputText.Count - 1 Then Bufferposition = -1
                    If Bufferposition < 0 Then
                        MomentanerInputText = ""
                    Else
                        MomentanerInputText = InputText(Bufferposition)
                    End If
                    TextInputPosition = MomentanerInputText.Length
                Case Keys.Right
                    TextInputPosition += 1
                    If TextInputPosition > MomentanerInputText.Length Then TextInputPosition = MomentanerInputText.Length

                Case Keys.Left
                    TextInputPosition -= 1
                    If TextInputPosition < 0 Then TextInputPosition = 0
                Case Keys.Back
                    If TextInputPosition > 0 Then
                        MomentanerInputText = MomentanerInputText.Remove(TextInputPosition - 1, 1)
                        TextInputPosition -= 1
                    End If
            End Select

            'Input loeschen
            TextInput.Text = ""
            BackgroundUpdate = False
        Else
            Select Case e.KeyCode
                Case DataSettings.AktivKonsole 'Konsole ausblenden oder anzeigen
                    AendereKonsolenStatus()
            End Select
        End If
        Return Aktiv
    End Function

    ''' <summary>
    ''' Loescht alle vorhandenen Eintraege
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Sub Clear()
        TextZeilen.Clear()
    End Sub

    ''' <summary>
    ''' Liest die Eingabe der Textbox ein.
    ''' </summary>
    ''' <remarks></remarks>
    Private Shared Sub DoBackgroundUpdate()
        If Input Then
            TextInputLocker.Lock()
            If Not BackgroundUpdate And TextInput.Text.Length > 0 Then
                MomentanerInputText = MomentanerInputText.Insert(TextInputPosition, TextInput.Text)
                TextInputPosition += TextInput.Text.Length
                BackgroundUpdate = True
                If MomentanerInputText.StartsWith("^") Then
                    MomentanerInputText = MomentanerInputText.Remove(0, 1)
                    TextInputPosition -= 1
                End If
            End If
            TextInputLocker.Unlock()
        End If
    End Sub
    ''' <summary>
    ''' Malt die Konsole auf den Bildschirm
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Sub Malen()

        If Aktiv Then
            'Eingabe einlesen
            DoBackgroundUpdate()

            For I = 0 To TextZeilen.Count - 1
                TextZeilen(I) = TextZeilen(I).Replace(Environment.NewLine, "")
            Next
            'Start berechnungen.
            Dim KonsolenGroesse As New Size
            KonsolenGroesse.Width = DataSettings.BildschirmBreite
            If Fullscreen Then
                If DataSettings.Fenstermodus Then
                    KonsolenGroesse.Height = (DataSettings.BildschirmHoehe - Hauptmenue.Rand.Y - Hauptmenue.Rand.X)
                Else
                    KonsolenGroesse.Height = (DataSettings.BildschirmHoehe)
                End If
            Else
                If DataSettings.Fenstermodus Then
                    KonsolenGroesse.Height = (DataSettings.BildschirmHoehe) / 2
                Else
                    KonsolenGroesse.Height = (DataSettings.BildschirmHoehe) / 2
                End If
            End If
            Grafikengine.Sprite.Transform = Matrix.Identity
            Dim BuchstabenGroesse As Size = Schriftengine.Fonts(Konsolenschrift).GetFont.MeasureString(Grafikengine.Sprite, "H", Microsoft.DirectX.Direct3D.DrawTextFormat.None, Color.Black).Size
            Dim BuchstabenZahlMax As Integer = Math.Round(KonsolenGroesse.Width / BuchstabenGroesse.Width, System.MidpointRounding.ToEven)
            Dim MaxZeilenZahl As Integer = Math.Round(KonsolenGroesse.Height / BuchstabenGroesse.Height, System.MidpointRounding.ToEven) - 2
            'Input Laenge berechnen
            Dim InputZeilen As New List(Of String)
            Dim I2 As Integer = 1
            If Input Then
                If MomentanerInputText.Length > BuchstabenZahlMax - 2 Then
                    InputZeilen.Add("> " + MomentanerInputText.Substring(0, BuchstabenZahlMax - 2))
                    While MomentanerInputText.Length > I2 * BuchstabenZahlMax - 2
                        Dim Buchstabenzahl As Integer = BuchstabenZahlMax
                        If MomentanerInputText.Length - (I2 * BuchstabenZahlMax - 2) < Buchstabenzahl Then
                            Buchstabenzahl = MomentanerInputText.Length - (I2 * BuchstabenZahlMax - 2)
                        End If
                        InputZeilen.Add(MomentanerInputText.Substring(I2 * BuchstabenZahlMax - 2, Buchstabenzahl))
                        I2 += 1
                    End While
                    I2 = 1
                Else
                    InputZeilen.Add("> " + MomentanerInputText)
                End If
            End If
            Dim MomZeilen As Integer = 2 + InputZeilen.Count  'unterste Eingabezeile
            Dim Textstart As Integer = TextZeilen.Count
            While MomZeilen < TextZeilenMax And Textstart > 0 And MomZeilen - 2 < MaxZeilenZahl


                Dim TextLaenge As Integer = TextZeilen(Textstart - 1).Length
                If Math.Round((TextLaenge / BuchstabenZahlMax), MidpointRounding.AwayFromZero) + MomZeilen - 2 < MaxZeilenZahl Then

                    Textstart -= 1
                    MomZeilen += 1
                    TextLaenge -= (BuchstabenZahlMax)

                    'Textabschneiden.
                    While TextLaenge > 0
                        MomZeilen += 1
                        TextLaenge -= BuchstabenZahlMax
                    End While
                Else
                    Exit While
                End If
            End While
            Grafikengine.fillRect(New Rectangle(New Point, KonsolenGroesse), Color.Black)
            Dim Zeilen As New List(Of String)

            For I = Textstart To TextZeilen.Count - 1
                Dim Text As String = TextZeilen(I)
                If Text.Length > BuchstabenZahlMax - 2 Then
                    Zeilen.Add("> " + Text.Substring(0, BuchstabenZahlMax - 2))
                    While Text.Length > I2 * BuchstabenZahlMax - 2
                        Dim Buchstabenzahl As Integer = BuchstabenZahlMax
                        If Text.Length - (I2 * BuchstabenZahlMax - 2) < Buchstabenzahl Then
                            Buchstabenzahl = Text.Length - (I2 * BuchstabenZahlMax - 2)
                        End If
                        Zeilen.Add(Text.Substring(I2 * BuchstabenZahlMax - 2, Buchstabenzahl))
                        I2 += 1
                    End While
                    I2 = 1
                Else
                    Zeilen.Add("> " + Text)
                End If
            Next

            'Input anzeigen!!!
            If Input Then
                Zeilen.AddRange(InputZeilen)
            End If
            Schriftengine.DrawTextZeile(Zeilen, New Point, Konsolenschrift, Color.Orange)
            'Cursur anzeigen...
            If Input Then
                If TextWriterVisible Then
                    Dim P As Integer = TextInputPosition + 2
                    Dim Z As Integer = 0
                    While P >= BuchstabenZahlMax
                        P -= BuchstabenZahlMax
                        Z += 1
                    End While
                    Dim MomAnzeigeZeilen As Integer = 0
                    Dim P1 As Integer = MomentanerInputText.Length + 2
                    While P1 > 0
                        P1 -= BuchstabenZahlMax
                        MomAnzeigeZeilen += 1
                    End While
                    Dim UStrich As String = ""
                    For I = 0 To P - 1
                        UStrich += " "
                    Next

                    Dim Y As Integer = (Zeilen.Count - MomAnzeigeZeilen + Z) * BuchstabenGroesse.Height

                    UStrich += "_"
                    Schriftengine.DrawTextZeile(UStrich, New Point(0, Y - 2), Konsolenschrift, Color.Orange)
                End If
            End If

            Frame += 1
            If Frame >= FrameChange Then
                Frame = 0
                TextWriterVisible = Not TextWriterVisible
            End If
        End If
    End Sub
End Class

